package com.sui.bigdata.rtcadmin.repository.model;

import com.sui.bigdata.rtcadmin.model.dto.ResourceInfoDto;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.ibatis.type.Alias;

import java.sql.Date;

/**
 * @Author: TingWuHuang
 * @Date: 2020/7/2 11:12
 * @description
 */
@Data
@Alias("ResourceInfo")
@Accessors(chain = true)
public class ResourceInfo {
    private String fileName;
    private String filePath;
    private String resource;
    private Date updateTime;
    private Date createTime;
    private long fileSize;
    private String remarks;

    public ResourceInfo() {
    }

    public ResourceInfo(String fileName, String filePath, String resource, long fileSize, String remarks) {
        this.fileName = fileName;
        this.filePath = filePath;
        this.resource = resource;
        this.fileSize = fileSize;
        this.remarks = remarks;
    }

    public static ResourceInfo buildResourceInfo(ResourceInfoDto resourceInfoDto){
        if(resourceInfoDto == null){
            return null;
        }
        return new ResourceInfo()
                .setFileName(resourceInfoDto.getFileName())
                .setFilePath(resourceInfoDto.getFilePath())
                .setFileSize(resourceInfoDto.getFileSize())
                .setRemarks(resourceInfoDto.getRemarks())
                .setCreateTime(resourceInfoDto.getCreateTime())
                .setUpdateTime(resourceInfoDto.getUpdateTime())
                .setResource(resourceInfoDto.getResource());
    }

    @Override
    public String toString() {
        return "ResourceInfo{" +
                "fileName='" + fileName + '\'' +
                ", filePath='" + filePath + '\'' +
                ", resource='" + resource + '\'' +
                ", updateTime=" + updateTime +
                ", createTime=" + createTime +
                ", fileSize=" + fileSize +
                ", remarks='" + remarks + '\'' +
                '}';
    }
}
